package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import org.example.bean.Seckill;
import org.example.bean.Seckill;
import org.example.mapper.SeckillMapper;
import org.example.service.SeckillService;
import org.example.util.DateUtil;
import org.example.util.JsonResult;
import org.example.util.ResultTool;
import org.springframework.stereotype.Service;

/**
 * @Auther:Liu
 * @Testname:SeckillServiceImpl
 * @Date:2025/8/28 12:38
 */
@Service
public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> implements SeckillService {
    /**
     * 添加秒杀
     *
     * @param seckill
     * @return
     */
    @Override
    public JsonResult addSeckill(Seckill seckill) {

        return ResultTool.success(save(seckill));
    }

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public JsonResult findAllSeckill() {
        return ResultTool.success(list());
    }

    /**
     * 查询符合条件的
     *
     * @return
     */
    @Override
    public JsonResult find() {
        QueryWrapper<Seckill> wrapper = new QueryWrapper<>();
        String s = DateUtil.nowDate();
        wrapper.eq("begin_time", s);
        wrapper.eq("end_time", s);
        return ResultTool.success(list(wrapper));
    }
}
